directives.directive('editorOneInput', ["$rootScope", "tools", "$timeout", "$location", function ($rootScope, tools, $timeout, $location) {
    return {
        restrict: 'AE',
        scope: {},
        replace: true,
        link: function (scope, element, attr) {

            scope.nameValue = null;  //对象
            scope.title = "";
            scope.operatorType = "";  //使用的type，用于不同的组件使用
            scope.id = null;

            /**
             * config data ---
             * title: '创建关联表的表名',
             * data: '',
             * type: 'ConnectTableName'  -- 用于组件的复用--类型
             */
            $rootScope.$on('EditorOneInput_EV', function (e, config) {

                $(element).modal('show');
               // console.log(config);
                scope.title = config.title;
                scope.id = config.id;
                scope.nameValue = config.data; //传入数据

                scope.operatorType = config.type;
            });

            scope.close = function () {


                $(element).modal('hide');
                if(scope.operatorType == "ConnectTableName") {
                    $rootScope.$broadcast('Edit_ConnectTableName_C_EV');
                }else if(scope.operatorType == "MulRelTableName"){
                    $rootScope.$broadcast("cancel_save_mulRelationAble_EV");
                }
                scope.nameValue = null;  //对象
                scope.title = "";
                scope.operatorType = "";  //使用的type，用于不同的组件使用

            };
            scope.ok = function () {
               // console.log("/*重命名的值： "+scope.nameValue+"操作类型："+scope.operatorType+"  */");

                if(scope.nameValue==null || scope.nameValue==""){
                    scope.errInfoShown = "请输入表名!";
                    $timeout(function(){
                        scope.errInfoShown = null;
                    },2000);
                    return;
                }
                $(element).modal('hide');
                //组件调用返回
                if(scope.operatorType == "ConnectTableName"){
                    $rootScope.$broadcast('Edit_ConnectTableName_EV',scope.nameValue,scope.id);
                }else if(scope.operatorType == "MulRelTableName"){
                    $rootScope.$broadcast('Edit_ConnectTableName_EV2',scope.nameValue,scope.id);
                }else if(scope.operatorType == "thRename"){
                    $rootScope.$broadcast('Edit_thRename_EV',scope.nameValue,scope.id);

                }else if(scope.operatorType == "tableRename"){

                    $rootScope.$broadcast("myTable_Rename_EV",scope.nameValue,scope.id);
                }
                scope.nameValue = null;

            };
        },
        templateUrl: "/trend-new-BI/app/components/common/editorOneInput/editorOneInputView.html"
    }
}]);